package seqlist.leetcode;

public class Num876 {
    // 快慢指针法
    public ListNode middleNode(ListNode head) {
        // fast一次走两步
        ListNode fast = head;
        // low一次走一步
        ListNode low = head;
        // 当fast为null(偶数个节点) || fast.next == null(奇数个节点)
        while (fast != null && fast.next != null) {
            low = low.next;
            fast = fast.next.next;
        }
        return low;
    }
}
